<template>
  <span>{{ text }}</span>
</template>

<script>
import { mapGetters } from 'vuex';

export default {
  name: "drugType",
  props: {
    value: {
      type: Number,
      default: 0
    }
  },
  computed: {
    ...mapGetters(["drugTypes"]),
    text() {
      return this.drugTypeMap[this.value];
    }
  },
  data() {
    return {
      drugTypeMap: {}
    }
  },
  created() {
    this.drugTypes.forEach(item => {
      this.$set(this.drugTypeMap, item.id, item.text);
    });
  }
}
</script>